'''
object-oriented

class:Student  which include student's name and score
class attribute: studentNum   which count the number of student

called method of class attribute: classname.studentNum; instancename.studentNum

example and test below
'''


class Student(object):
    # function self point to the created instance itself
    #
    studentNum = 0  # Class attribute:classname.studentNum; instancename.studentNum

    def __init__(self, name, score):
        self.__name__ = name
        self.__score__ = score
        Student.studentNum += 1

    def print_score(self):
        print('%s: %s' % (self.__name__, self.__score__))

    def get_grade(self):
        if self.__score__ >= 90:
            return 'A'
        elif self.__score__ >= 60:
            return 'B'
        else:
            return 'C'


xiaolv = Student('xiaolv', 85)
# test
print('the grade of xiaolv: %s' % xiaolv.get_grade())
print('the grade of xiaolv: %s' % xiaolv.studentNum)
# print('the number of studentz: %s' % get_student_num())

xiaoh = Student('xiaoh', 45)
# test
print('the number of students: %s' % Student.studentNum)

xiaoi = Student('xiaoi', 78)
# test
print('the number of students: %s' % Student.studentNum)

xiaoj = Student('xiaoj', 94)
# test
print('the number of students: %s' % Student.studentNum)
print('the number of students: %s' % xiaolv.studentNum)
